#include <linux/init.h>
#include <linux/module.h>

#include <linux/fs.h>
#include <linux/miscdevice.h>



struct file_operations misc_fops = {
    .owner = THIS_MODULE,
};


struct miscdevice misc_dev = {
    .minor = MISC_DYNAMIC_MINOR,
    .name = "misc_test",
    .fops = &misc_fops,
};


static int __init misc_dev_init(void)
{
    int ret;

    ret = misc_register(&misc_dev);
    if (ret < 0)
    {
        printk(KERN_EMERG "misc register error\r\n");
        return -1;
    }
    printk(KERN_EMERG "misc register ok\r\n");

    return 0;
}

static void __exit misc_dev_exit(void)
{
    misc_deregister(&misc_dev);
    printk(KERN_EMERG "module exit\r\n");
}


module_init(misc_dev_init);
module_exit(misc_dev_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("treasure1029");





